#ifndef PROCESS_H
# define PROCESS_H

#include "linuxos.h"

#define PROCESS_C_MAX 256

#define PROC_PID_DIR        "/proc/"
#define PROC_PID_COMM       "comm"
#define PROC_PID_CMDLINE    "cmdline"

typedef struct _ProcProcess {
    char autogroup[PROCESS_C_MAX];
    char auxv[PROCESS_C_MAX];
    char cgroup[PROCESS_C_MAX];
    char cmdline[PROCESS_C_MAX];
    char comm[PROCESS_C_MAX];
    char coredump_filter[PROCESS_C_MAX];
    char cpuset[PROCESS_C_MAX];
    char environ[PROCESS_C_MAX];
    char gid_map[PROCESS_C_MAX];
    char io[PROCESS_C_MAX];
    char limits[PROCESS_C_MAX];
    char loginuid[PROCESS_C_MAX];
    char maps[PROCESS_C_MAX];
    char mem[PROCESS_C_MAX];
    char mountinfo[PROCESS_C_MAX];
    char mounts[PROCESS_C_MAX];
    char mountstats[PROCESS_C_MAX];
    char oom_adj[PROCESS_C_MAX];
    char oom_score[PROCESS_C_MAX];
    char oom_score_adj[PROCESS_C_MAX];
    char pagemap[PROCESS_C_MAX];
    char personality[PROCESS_C_MAX];
    char projid_map[PROCESS_C_MAX];
    char sched[PROCESS_C_MAX];
    char schedstat[PROCESS_C_MAX];
    char sessionid[PROCESS_C_MAX];
    char setgroups[PROCESS_C_MAX];
    char smaps[PROCESS_C_MAX];
    char smaps_rollup[PROCESS_C_MAX];
    char stack[PROCESS_C_MAX];
    char stat[PROCESS_C_MAX];
    char statm[PROCESS_C_MAX];
    char status[PROCESS_C_MAX];
    char syscall[PROCESS_C_MAX];
    char timers[PROCESS_C_MAX];
    char timerslack_ns[PROCESS_C_MAX];
    char uid_map[PROCESS_C_MAX];
    char wchan[PROCESS_C_MAX];
} ProcProcess;

static const char proc_pid_properties[][20] = {
                                    "autogroup",       // 0
                                    "auxv",            // 1
                                    "cgroup",          // 2
                                    "cmdline",         // 3
                                    "comm",            // 4
                                    "coredump_filter", // 5
                                    "cpuset",          // 6
                                    "environ",         // 7
                                    "gid_map",         // 8
                                    "io",              // 9
                                    "limits",          // 10
                                    "loginuid",        // 11
                                    "maps",            // 12
                                    "mem",             // 13
                                    "mountinfo",       // 14
                                    "mounts",          // 15
                                    "mountstats",      // 16
                                    "oom_adj",         // 17
                                    "oom_score",       // 18
                                    "oom_score_adj",   // 19
                                    "pagemap",         // 20
                                    "personality",     // 21
                                    "projid_map",      // 22
                                    "sched",           // 23
                                    "schedstat",       // 24
                                    "sessionid",       // 25
                                    "setgroups",       // 26
                                    "smaps",           // 27
                                    "smaps_rollup",    // 28
                                    "stack",           // 29
                                    "stat",            // 30
                                    "statm",           // 31
                                    "status",          // 32
                                    "syscall",         // 33
                                    "timers",          // 34
                                    "timerslack_ns",   // 35
                                    "uid_map",         // 36
                                    "wchan",           // 37
                                    };

// bool proc_pid_cmdline_of_path(int pid, ProcProcess *info) {}
// bool proc_pid_comm_of_path(int pid, ProcProcess *info) {}

// bool proc_pid_comm_of_buffer(int pid, ProcProcess *info) {
//     if (isNull(buf)) return false;
//     return true;
// }

bool get_comm_by_pid(char *pid, char *comm, size_t len);
bool initProcessByPid(int pid, ProcProcess *info);



#endif